package com.cheng.chengrobot.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cheng.chengrobot.mappers.RobotMapper;
import com.cheng.chengrobot.domain.Robot;
import net.mamoe.mirai.event.events.FriendMessageEvent;
import net.mamoe.mirai.message.data.MessageChain;
import net.mamoe.mirai.message.data.SingleMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ShopService
{
    @Autowired
    RobotMapper robotMapper;

    public void executeFriendMessage(FriendMessageEvent event)
    {
        QueryWrapper<Robot> wrapper = new QueryWrapper<>();
        wrapper.eq("qq", event.getBot().getId());
        Robot robot = robotMapper.selectOne(wrapper);
        if (!robot.getShop())
        {
            return;
        }
        String messageStr = "";
        MessageChain messageChain = event.getMessage();
        for(SingleMessage singleMessage:messageChain)
        {
            messageStr += singleMessage.toString();
        }
        System.out.println(messageStr);
        return;
    }
}
